Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add value_counts. #63

Merged
merged 4 commits into from Apr 9, 2019
Merged

Add value_counts. #63

merged 4 commits into from Apr 9, 2019

Conversation

ueshin
Copy link
Collaborator

@ueshin ueshin commented Apr 8, 2019

No description provided.

@ueshin
Copy link
Collaborator Author

ueshin commented Apr 8, 2019

cc @thunterdb

Copy link
Contributor

@thunterdb thunterdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ueshin just a small question that can be solved by a comment. Feel free to merge the pull request after adding that comment. Great work!

raise NotImplementedError("value_counts currently does not support bins")

if dropna:
df_dropna = self.to_dataframe().filter(self._spark_isNotNull())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this enough to filter not only the null but also the NaNs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but I am also marking this as something to cover in the guide in #34 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thunterdb updated to check the NaNs.

Copy link
Contributor

@thunterdb thunterdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ueshin a small refacting comment. This method is going to be very useful!


if dropna:
if isinstance(self.schema[self.name].dataType, (FloatType, DoubleType)):
pred = ~(self._spark_isNull() | F._spark_isnan(self))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just implemented Series.isnull(). This is fine, we can refactor this piece later. I made an issue to do that later.

@@ -534,10 +560,14 @@ def dropna(self, axis=0, how='any', thresh=None, subset=None, inplace=False):
else:
columns = list(self.columns)

def pred(c):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are repeating this logic twice already, would you mind going the whole way and defining PandasLikeSeries.inull? We can add the tests later when fully implementing #64


isnull = isna

def notna(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a doc here when working on #64.

@@ -260,6 +260,17 @@ def to_dataframe(self):
def toPandas(self):
return _col(self.to_dataframe().toPandas())

def isna(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Copy link
Contributor

@thunterdb thunterdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ueshin this is much cleaner now, thanks. Merging

@thunterdb thunterdb merged commit a5a0627 into databricks:master Apr 9, 2019
@ueshin ueshin deleted the value_counts branch April 9, 2019 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants